package com.complex.getejb.dao;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class DBConnectionPoolUsage {
    private static Connection conn = null;

    public static Connection getDBConnection() {
        try {
            conn = ((DataSource) new InitialContext().lookup("testDataSource")).getConnection();
        } catch (SQLException e) {
            new GetDAOBeanException("Bad connection or data source!", e);
        } catch (NamingException e) {
            new GetDAOBeanException("Can't gen context!", e);
        }
        return conn;
    }
}
